package cn.smile.commons.exceptions;

import cn.smile.commons.response.MyResponseCode;
import lombok.Getter;
import lombok.Setter;

import java.io.Serial;

/**
 * <p>
 * 全局业务异常
 * </p>
 *
 * @author longjuntao
 * @since 2020/8/25 15:32
 */
@Setter
@Getter
@SuppressWarnings("unused")
public class BusinessException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = -4546779323359670022L;

    private Integer code;

    public BusinessException(String message) {
        super(message);
        this.code = -1;
    }

    public BusinessException(MyResponseCode status) {
        super(status.message());
        this.code = status.code();
    }

    public BusinessException(MyResponseCode status, String message) {
        super(message);
        this.code = status.code();
    }
}
